<?php
/**
 * Created by PhpStorm.
 * User: yandian
 * Date: 16/9/8
 * Time: 16:56
 */

namespace app\common\util;


use think\Exception;

class DbUtil
{
    public static function execSqlFile($file)
    {
        $sql = trim(file_get_contents($file));
        if (!$sql) {
            return;
        }
        $db = M();
        $db->execute($sql);
        $error = $db->getError();
        if (!empty($error)) {
            throw new Exception($error);
        }
    }

    public static function getDictList($modelname, $fiels = "id,title")
    {
        return M($modelname)->field($fiels)->select();
    }
}